/*
 * =====================================================================================
 *
 *       Filename:  getip.cpp
 *
 *    Description:  Get ip with command: curl ipinfo.io
 *
 *        Version:  1.0
 *        Created:  09/28/15 13:38:21
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Andy (gk), andy_y_li@163.com
 *        Company:  RD
 *
 * =====================================================================================
 */

#include "strRegex.h"

int main()
{
    const char *cmd = "curl ipinfo.io";
    //char *result = executeShellCmd(cmd);
    //const char *result = "\"ip\": \"27.38.44.202\",";
    //const char *result = "10.18.6.154";
    //const char *pattern = "\"ip\": \"(\\d{1,3}\.\\d{1,3}\.\\d{1,3}\.\\d{1,3})\",";
    //const char* pattern = "(.{1,3}\..{1,3}\..{1,3}\..{1,3})";
    const char *result = "sadsfsfs@163.com";
    const char *pattern = "^(\\w+@\\w+.\\w+)";
    StrPattern *p = new StrPattern(result, pattern);
    if (p->result() == OK) {
        printf("IP:%s\n", p->getMatchString(0));
    }
    else{
        printf("Can't get IP\n");
    }
    delete p;

    return 0;
}

